package com.example.fireassistant_server.entity;

import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Table(name = "poi")
@Entity
@Data
public class PoiEntity {
    @Id
    @Column(name = "id", nullable = false)
    private String id;

    private BigDecimal latitude;

    private BigDecimal longitude;

    private String name;

    private String description;

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    private User user;

    @ManyToMany(fetch = FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    @JoinTable(name = "poi_file", joinColumns = @JoinColumn(name = "poi_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "file_id", referencedColumnName = "id"))
    private List<File> Files;

    @CreationTimestamp
    private Date created_time;

    @UpdateTimestamp
    private Date updated_time;


}
